<template>
<div class="vue-box sbot sbot-fluid">
  <el-form class="ads-panel" :inline="true">
    <!-- 表单 -->
    <sa-item v-model="m.name" type="text" name="广告名" br />
    <sa-item v-model="m.code" type="text" name="识别码" placeholder="请输入识别码，请尽量以 ADS_ 开头" br p />
    <sa-item v-model="m.type" type="enum" jtype="4" :jv="dims.ADS_TYPE" name="类型" br />
    <sa-item v-model="m.resourceId" type="enum" jtype="4" :jv="dims.ADS_LOCATION_ID_NAME" name="广告定位" br />
    <sa-item v-model="m.url" type="text" name="广告URL" br />
    <sa-item v-model="m.img" type="img" name="LOGO" br />
    <sa-item v-model="m.thumbnail" type="img-list" name="广告图" br />
    <sa-item v-model="m.note" type="textarea" name="备注" br />
  </el-form>
</div>
</template>

<script>
export default {
  name: 'check-ads',
  props: {
    param: Object
  },
  data() {
    return {
      // 超级对象
      m: this.createModel(),
      dims: sa.$sys.getCurd()
    }
  },
  methods: {
    createModel() {
      return {
        id: this.param.item.id,
        name: this.param.item.name,
        code: this.param.item.code,
        type: this.param.item.type,
        url: this.param.item.url,
        img: this.param.item.img,
        thumbnail: this.param.item.thumbnail,
        note: this.param.item.note,
        resourceId: this.param.item.resourceId,
      }
    },
    // 变更
    ok: function () {
      // 表单校验
      let m = this.m;
      sa.checkNull(m.name, '请输入广告名');
      sa.checkNull(m.code, '请输入识别码');
      // 添加
      sa.ajax('/ads/apply/check-in', m, function (res) {
        if (res.code == 200) {
          sa.alert(res.msg, function () {
            this.m = this.createModel();
            sa.closeModel();
            sa.f5()
          }.bind(this));
        }
      }.bind(this), {
        type: 'post'
      });
    },
  }
}
</script>

<style scoped>
</style>
